<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>数据可视化</title>
    <!-- Bootstrap core CSS -->
    <link href="asserts/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="asserts/css/dashboard.css" rel="stylesheet">
    <style type="text/css">
        /* Chart.js */

        @-webkit-keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        @keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        .chartjs-render-monitor {
            -webkit-animation: chartjs-render-animation 0.001s;
            animation: chartjs-render-animation 0.001s;
        }
    </style>
</head>

<body>
<div th:insert="~{commons/commons::topbar}"></div>

<div class="container-fluid">
    <div class="row">
        <div th:insert="~{commons/commons::sidebar(active='line.html')}"></div>
        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <!-- 为 ECharts 准备一个具备大小（宽高）-->
            <div id="main" style="width: 100%;height:600px;"></div>
            <div align="center">
                <button type="button" class="btn btn-primary" id = "loginNum">每日登录人数</button>
                <button type="button" class="btn btn-primary" id = "video">每日播放视频数</button>
                <button type="button" class="btn btn-primary" id = "courseNum">每日新增课程</button>
                <button type="button" class="btn btn-primary" id = "registerNum">每日新增课程</button>
            </div>

            <script src="https://cdn.bootcss.com/echarts/4.6.0/echarts.min.js"></script>
            <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
            <script type="text/javascript" th:inline="javascript">

                // 基于准备好的dom，初始化echarts实例

                var myChart = echarts.init(document.getElementById('main'));


                var xData = [[${dataLine.calculatedList}]];
                var yData = [[${dataLine.numDateList}]];

                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: '网站每日登录人数'
                    },
                    xAxis: {
                        type: 'category',
                        data: xData
                    },
                    yAxis: {
                        type: 'value'
                    },
                    toolbox: {
                        show: true,
                        feature: {
                            mark: {show: true},
                            dataView: {show: true, readOnly: false},
                            restore: {show: true},
                            saveAsImage: {show: true}
                        }
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    series: [{
                        data: yData,
                        type: 'line',
                        showBackground: true,
                        color: '#18cbdb',
                    }]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);

                $("#loginNum").click(function change() {
                    $.ajax({
                        type : "get",
                        url : "/getLineLogin",
                        contentType: 'application/json',
                        success:function(data){
                            console.log(data.calculatedList)
                            console.log(data.numDateList)
                            option = {
                                title: {
                                    text: '网站每日登录人数'
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.calculatedList
                                },
                                yAxis: {
                                    type: 'value'
                                },
                                toolbox: {
                                    show: true,
                                    feature: {
                                        mark: {show: true},
                                        dataView: {show: true, readOnly: false},
                                        restore: {show: true},
                                        saveAsImage: {show: true}
                                    }
                                },
                                tooltip: {
                                    trigger: 'axis',
                                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                                    }
                                },
                                series: [{
                                    data: data.numDateList,
                                    type: 'line',
                                    showBackground: true,
                                    color: '#18cbdb',
                                }]
                            };
                            // 使用刚指定的配置项和数据显示图表。
                            myChart.setOption(option);
                        },
                        error:function(data){
                            console.log("error")
                            console.log(data)
                        }
                    })

                });
                $("#video").click(function change() {
                    $.ajax({
                        type : "get",
                        url : "/getLineVideo",
                        contentType: 'application/json',
                        success:function(data){
                            console.log(data.calculatedList)
                            console.log(data.numDateList)
                            option = {
                                title: {
                                    text: '网站每日视频播放数'
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.calculatedList
                                },
                                yAxis: {
                                    type: 'value'
                                },
                                toolbox: {
                                    show: true,
                                    feature: {
                                        mark: {show: true},
                                        dataView: {show: true, readOnly: false},
                                        restore: {show: true},
                                        saveAsImage: {show: true}
                                    }
                                },
                                tooltip: {
                                    trigger: 'axis',
                                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                                    }
                                },
                                series: [{
                                    data: data.numDateList,
                                    type: 'line',
                                    showBackground: true,
                                    color: '#18cbdb',
                                }]
                            };
                            // 使用刚指定的配置项和数据显示图表。
                            myChart.setOption(option);
                        },
                        error:function(data){
                            console.log("error")
                            console.log(data)
                        }
                    })

                });
                $("#courseNum").click(function change() {
                    $.ajax({
                        type : "get",
                        url : "/getLineCourse",
                        contentType: 'application/json',
                        success:function(data){
                            console.log(data.calculatedList)
                            console.log(data.numDateList)
                            option = {
                                title: {
                                    text: '网站每日新增课程数'
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.calculatedList
                                },
                                yAxis: {
                                    type: 'value'
                                },
                                toolbox: {
                                    show: true,
                                    feature: {
                                        mark: {show: true},
                                        dataView: {show: true, readOnly: false},
                                        restore: {show: true},
                                        saveAsImage: {show: true}
                                    }
                                },
                                tooltip: {
                                    trigger: 'axis',
                                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                                    }
                                },
                                series: [{
                                    data: data.numDateList,
                                    type: 'line',
                                    showBackground: true,
                                    color: '#18cbdb',
                                }]
                            };
                            // 使用刚指定的配置项和数据显示图表。
                            myChart.setOption(option);
                        },
                        error:function(data){
                            console.log("error")
                            console.log(data)
                        }
                    })

                });
                $("#registerNum").click(function change() {
                    $.ajax({
                        type : "get",
                        url : "/getLineRegister",
                        contentType: 'application/json',
                        success:function(data){
                            console.log(data.calculatedList)
                            console.log(data.numDateList)
                            option = {
                                title: {
                                    text: '网站每日注册人数'
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.calculatedList
                                },
                                yAxis: {
                                    type: 'value'
                                },
                                toolbox: {
                                    show: true,
                                    feature: {
                                        mark: {show: true},
                                        dataView: {show: true, readOnly: false},
                                        restore: {show: true},
                                        saveAsImage: {show: true}
                                    }
                                },
                                tooltip: {
                                    trigger: 'axis',
                                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                                    }
                                },
                                series: [{
                                    data: data.numDateList,
                                    type: 'line',
                                    showBackground: true,
                                    color: '#18cbdb',
                                }]
                            };
                            // 使用刚指定的配置项和数据显示图表。
                            myChart.setOption(option);
                        },
                        error:function(data){
                            console.log("error")
                            console.log(data)
                        }
                    })

                });
            </script>

        </main>
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="asserts/js/popper.min.js"></script>
<script type="text/javascript" src="asserts/js/bootstrap.min.js"></script>

<!-- Icons -->
<script type="text/javascript" src="asserts/js/feather.min.js"></script>
<script>
    feather.replace()
</script>
</body>

</html>